  character*(*),parameter::PROGRAM="emily"
  character*(*),parameter::VERSION="version 0.9.15_1"
  character*(*),parameter::COPYRIGHT="Copyleft (!c) 2011 Elseif Laboratory.\n"//&
       "All rights reversed."  
  character*(*),parameter::BUILD_TIME='Sun Nov 20 11:13:49 JST 2011'
  character*(*),parameter::HOST_NAME='regulus.elseifkk.com'
  character*(*),parameter::NOTICE="This is free software; see the soruce for copying conditions.  There is NO\n"//&
       "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
  !
  character*(*),parameter::USAGE=&
       "Usage:\n"//&
       "\temily [-i|[-l]] input_data...\n"//&
       "\t -x num_crystal_x -d num_detector -X num_crystal_x_in_head -y num_crystal_y\n"//&
       "\t -D detector_separation [options]\n\n"//&
       "Description:\n"//&
       "or some note for developers, may i say.\n"//&
       "num_crystal_x = num_detector * (num_crystal_x_in_head + num_crystal_in_gap\n"//&
       "                - num_crystal_in_gap\n"//&
       "\n\n"//&
       "Options:\n"//&
       "\t-a value\t maximum crystal difference.\n"//&
       "\t-c\t\t show some statistics about\n"//&
       "\t-d value\t number of detectors in a head.\n"//&
       "\t-f\t\t force overwrite.\n"//&
       "\t-g value\t number of crystals in a gap.\n"//&
       "\t-h\t\t print usage.\n"//&
       "\t-i file\t\t input histogram file.\n"//&
       "\t-l file\t\t input listmode file.\n"//&
       "\t-m value=[1|4|9]\n\t\t\t set multiray sampling.\n"//&
       "\t-n file\t\t histogram for nomalization.\n"//&
       "\t-o file\t\t output file.\n"//&
       "\t-p value\t threshold for Cj (0 -> 1).\n"//&
       "\t-q\t\t quiet mode.\n"//&
       "\t-s value\t DOI sampling step in mm.\n"//&
       "\t-t \t\t try decay correction.\n"//&
       "\t-u \t\t try calibration by dose/weight.\n"//&      
       "\t-v\t\t verbose mode.\n"//&
       "\t-w\t\t write images for each iteration.\n"//&
       "\t-x value\t number of crystal in x.\n"//&
       "\t-y value\t number of crystal in y.\n"//&
       "\t-z value\t number of DOI sampling.\n"//&
       "\t-C value=[0|1]\t sysmat evaluator. 0 = Siddon, 1 = Gaussian.\n"//&
       "\t-D value\t detector separation in mm.\n"//&
       "\t-E value\t Voxel alignment mode.\n"//&
       "\t-F value\t AA filter amplitude.\n"//&
       "\t-G\t\t no pause when debug mode.\n"//&
       "\t-L\t\t use logL.\n"//&
       "\t-M\t\t use shared memory for I/O.\n"//&
       "\t-N value\t maximum iteration.\n"//&
       "\t-O\t\t use OS algorithm.\n"//&
       "\t-P value\t threshold for Ui (0 -> 1).\n"//&
       "\t-R\t\t automatically rename file upon overwriting.\n"//&
       "\t-S\t\t calculate only sysmat.\n"//&
       "\t-T\t\t use delayed subtracted histogram.\n"//&
       "\t-U\t\t Use uniform image as inital guess.\n"//&
       "\t-V\t\t print version.\n"//&
       "\t-W\t\t write in integer.\n"//&
       "\t-X value\t number of crystal in a detector.\n"//&
       "\t-Z value\t voxel height.\n"//&
       "\t--Cj file\t read Cj from file.\n"//&
       "\t--Ci file\t read Ci from file.\n"//&
       "\t--cf value\t calibration factor\n"//&
       "\t--debug\t\t debug mode. implies -cv\n"//&
       "\t--dump-Ci file.\n"//&
       "\t--dump-Ui file.\n"//&
       "\t--dump-projection.\n"//&
       "\t--flip-b1\n"//&
       "\t--flip-x1\n"//&
       "\t--flip-x2\n"//&
       "\t--flip-y1\n"//&
       "\t--write-Cj\n"//&
       "\t--write-hist-delayed file.\n"//&
       "\t--write-hist-prompt file.\n"//&
       "\t--write-hist-true file.\n"//&
       "\t--write-update\n"//&
       "\t--ofmt string\tOutput file format: raw, analyze dicom\n"//&
       "\t--range value:value\t\n\t\t\t slice range. midplane=0\n"//&
       "\t--read-sysmat file.\n"//&
       "\t--save-sysmat file.\n"
  !
  integer,public,parameter::OPT_NOP           = int(z'0000000000000000',8)
  integer,public,parameter::OPT_VERBOSE       = int(z'0000000000000001',8)
  integer,public,parameter::OPT_DUMP_PROJ     = int(z'0000000000000002',8)
  integer,public,parameter::OPT_WRITE_IMAG    = int(z'0000000000000004',8)
  integer,public,parameter::OPT_WRITE_UPDT    = int(z'0000000000000008',8)
  integer,public,parameter::OPT_WRITE_CJ      = int(z'0000000000000010',8)
  integer,public,parameter::OPT_DUMP_CI       = int(z'0000000000000020',8)
  integer,public,parameter::OPT_DUMP_UI       = int(z'0000000000000040',8)
  integer,public,parameter::OPT_USE_LOGL      = int(z'0000000000000080',8)
  integer,public,parameter::OPT_USE_OSEM      = int(z'0000000000000100',8)
  integer,public,parameter::OPT_USE_FILTER    = int(z'0000000000000200',8)
  integer,public,parameter::OPT_NORMALIZE     = int(z'0000000000000400',8)
  integer,public,parameter::OPT_ALLOW_OVERWRT = int(z'0000000000000800',8)
  integer,public,parameter::OPT_SYSMAT_ONLY   = int(z'0000000000001000',8)
  integer,public,parameter::OPT_WRITE_INTEGER = int(z'0000000000002000',8)
  integer,public,parameter::OPT_USE_SHM       = int(z'0000000000008000',8)

  integer,public,parameter::OPT_READ_32       = int(z'0000000000020000',8)
  integer,public,parameter::OPT_LOAD_CJ       = int(z'0000000000040000',8)
  integer,public,parameter::OPT_LOAD_CI       = int(z'0000000000080000',8)
  integer,public,parameter::OPT_LOAD_SYSMAT   = int(z'0000000000100000',8)
  integer,public,parameter::OPT_SAVE_CJ       = int(z'0000000000200000',8)
  integer,public,parameter::OPT_SAVE_CI       = int(z'0000000000400000',8)
  integer,public,parameter::OPT_SAVE_SYSMAT   = int(z'0000000000800000',8)
  integer,public,parameter::OPT_UNIFORM_INIT  = int(z'0000000001000000',8)

  integer,public,parameter::OPT_NO_PAUSE      = int(z'0000000004000000',8)
  integer,public,parameter::OPT_DEBUG         = int(z'0000000008000000',8)
  integer,public,parameter::OPT_SHOW_STAT     = int(z'0000000010000000',8)
  integer,public,parameter::OPT_RENAME        = int(z'0000000020000000',8)
  integer,public,parameter::OPT_USE_TRUE      = int(z'0000000040000000',8)

  integer,public,parameter::OPT_DECAY_CORRECTION      = int(z'0000000080000000',8)  
  integer,public,parameter::OPT_CALIBRATION           = int(z'0000000100000000',8)  

  integer,public,parameter::OPT_LMD_FLIPB1     = int(z'1000000000000000',8)
  integer,public,parameter::OPT_LMD_FLIPX1     = int(z'2000000000000000',8) 
  integer,public,parameter::OPT_LMD_FLIPX2     = int(z'4000000000000000',8)
  integer,public,parameter::OPT_LMD_FLIPY1     = int(z'8000000000000000',8) 

  !
  integer,parameter::lenpc=7
  integer*1::prefcode(7)=[116_1,104_1,105_1,115_1,32_1,105_1,115_1]
  integer,parameter::lencc=4
  integer*1::captaincode(lencc)=[109_1,97_1,110_1,97_1]
  integer,parameter::lensc=16
  integer*1::shipcode(lensc)=[117_1,115_1,115_1,32_1,108_1,111_1,110_1,103_1,115_1,104_1,&
       111_1,116_1,32_1,73_1,73_1,73_1]
  integer,parameter::lenbc=14
  integer*1::basecode(14)=[103_1,114_1,111_1,117_1,110_1,100_1,32_1,99_1,111_1,110_1,&
       116_1,114_1,111_1,108_1]

  integer,parameter::MSG_GC=1
  integer,parameter::MSG_CAP=2
  integer,parameter::NMSGMAX=4
  integer*1::gcmsg(148)=[116_1,97_1,107_1,101_1,32_1,121_1,111_1,117_1,114_1,32_1,&
       112_1,114_1,111_1,116_1,101_1,105_1,110_1,32_1,112_1,105_1,&
       108_1,108_1,115_1,32_1,97_1,110_1,100_1,32_1,112_1,117_1,&
       116_1,32_1,121_1,111_1,117_1,114_1,32_1,104_1,101_1,108_1,&
       109_1,101_1,116_1,32_1,111_1,110_1,44_1,32_1,103_1,114_1,&
       101_1,101_1,110_1,63_1,0_1,&
       99_1,111_1,109_1,109_1,101_1,110_1,99_1,105_1,110_1,103_1,&
       32_1,99_1,111_1,117_1,110_1,116_1,32_1,100_1,111_1,119_1,&
       110_1,32_1,101_1,110_1,103_1,105_1,110_1,101_1,115_1,32_1,&
       111_1,110_1,44_1,32_1,103_1,114_1,101_1,101_1,110_1,63_1,0_1,&
       99_1,104_1,101_1,99_1,107_1,32_1,105_1,103_1,110_1,105_1,&
       116_1,105_1,111_1,110_1,44_1,32_1,97_1,110_1,100_1,46_1,&
       46_1,46_1,0_1,&
       110_1,111_1,119_1,32_1,114_1,101_1,108_1,101_1,97_1,115_1,&
       101_1,32_1,71_1,67_1,32_1,118_1,101_1,116_1,111_1,44_1,&
       32_1,103_1,114_1,101_1,101_1,110_1,63_1,0_1,-1_1]
  integer*1::capmsg(51)=[104_1,101_1,97_1,108_1,116_1,104_1,32_1,99_1,104_1,101_1,&
       99_1,107_1,46_1,46_1,46_1,0_1,&
       101_1,110_1,103_1,105_1,110_1,101_1,32_1,115_1,116_1,97_1,&
       116_1,117_1,115_1,46_1,46_1,46_1,0_1,&
       99_1,104_1,101_1,107_1,105_1,110_1,103_1,46_1,46_1,46_1,0_1,&
       97_1,45_1,111_1,107_1,44_1,0_1,-1_1]
  
  integer,parameter::nofmt=3
  character*8,parameter::valid_ofmt(nofmt)=[&
       "raw     ",&
       "analyze ",&
       "dicom   "]
  character*4,parameter::ofmt_ext(nofmt)=[&
       ".img",&
       ".img",&
       ".dcm"]
  integer,parameter,public::OFMT_NOP = 0
  integer,parameter,public::OFMT_RAW = 1
  integer,parameter,public::OFMT_ANA = 2
  integer,parameter,public::OFMT_DCM = 3
    
